import request from '@/router/axios';
import {baseUrl} from '@/config/env';

export const list = (data) => {
    return request({
            url: baseUrl + '/start/quartz/page',
            method: 'get',
            data: data
        }
    )
}
export const add = (data) => {
    return request({
            url: baseUrl + '/start/quartz/add',
            method: 'post',
            data: data
        }
    )
}

export const updateById = (id, data, index) => {
    return request({
            url: baseUrl + '/start/quartz/updateById',
            method: 'put',
            data: data
        }
    )
}

export const deleteById = (id) => {
    return request({
            url: baseUrl + '/start/quartz/deleteById/' + id,
            method: 'delete',
        }
    )
}
/**
 * 激活任务
 * @param id
 * @returns {AxiosPromise}
 */
export const activeById = (id) => {
    return request({
            url: baseUrl + '/start/quartz/activeById/' + id,
            method: 'get',
        }
    )
}
/**
 * 禁用任务
 * @param id
 * @returns {AxiosPromise}
 */
export const disableById = (id) => {
    return request({
            url: baseUrl + '/start/quartz/disableById/' + id,
            method: 'get',
        }
    )
}
/**
 * 暂停任务
 * @param id
 * @returns {AxiosPromise}
 */
export const pauseById = (id) => {
    return request({
            url: baseUrl + '/start/quartz/pauseById/' + id,
            method: 'get',
        }
    )
}
/**
 * 暂停全部任务
 * @param id
 * @returns {AxiosPromise}
 */
export const pauseAll = () => {
    return request({
            url: baseUrl + '/start/quartz/pauseAll',
            method: 'get',
        }
    )
}
/**
 * 恢复任务
 * @param id
 * @returns {AxiosPromise}
 */
export const recoveryById = (id) => {
    return request({
            url: baseUrl + '/start/quartz/recoveryById/' + id,
            method: 'get',
        }
    )
}
/**
 * 恢复全部任务
 * @returns {AxiosPromise}
 */
export const recoveryAll = () => {
    return request({
            url: baseUrl + '/start/quartz/recoveryAll',
            method: 'get',
        }
    )
}
/**
 * 立即执行任务
 * @param id
 * @returns {AxiosPromise}
 */
export const startById = (id) => {
    return request({
            url: baseUrl + '/start/quartz/startById/' + id,
            method: 'get',
        }
    )
}
export const downloadTemplate = () => {
    return request({
            url: baseUrl + '/start/quartz/downloadTemplate',
            method: 'get',
            responseType: 'blob'
        }
    )
}

export const exportExcel = (data) => {
    return request({
            url: baseUrl + '/start/quartz/exportFile',
            method: 'get',
            responseType: 'blob',
            data: data
        }
    )
}

